{% comment %}
    Renders a set of links for paginated results. Must be used within paginate tags.

    Usage:
    {% paginate results by 2 %}
      {% render 'pagination', paginate: paginate, anchor: '#yourID' %}
    {% endpaginate %}

    Accepts:
    - paginate: {Object}
    - anchor: {String} (optional) This can be added so that on page reload it takes you to wherever you've placed your anchor tag.
    - class: {String} (optional) Appended to container element's class attribute
{% endcomment %}


{%- if paginate.parts.size > 0 -%}
  <div class="container">
    <nav class="pagination" role="navigation" aria-label="{{ 'general.pagination.label' | t }}">
      <ul class="justify-content-center mb-0 d-flex w-100 text-center pagination" role="list">
      {%- if paginate.previous -%}
        <li class="page-item col-1" style="max-width: 40px;">
          <a class="as-pagination-link text-body icon-wrap-md" data-page="{{ paginate.current_page | minus: 1 }}" href="{{ paginate.previous.url }}{{ anchor }}" aria-label="{{ 'general.pagination.previous' | t }}">
            {% render 'icon-chevron-left' %}
          </a>
        </li>
      {%- endif -%}

      {%- for part in paginate.parts -%}
        <li class="page-item col-1" style="max-width: 40px;">
          {%- if part.is_link -%}
            <a href="{{ part.url }}{{ anchor }}" data-page="{{ forloop.index }}" class="as-pagination-link text-decoration-none text-muted small" aria-label="{{ 'general.pagination.page' | t: number: part.title }}">{{ part.title }}</a>
          {%- else -%}
            {%- if part.title == paginate.current_page -%}
              <span class="small fw-bold" aria-current="page" aria-label="{{ 'general.pagination.page' | t: number: part.title }}">{{ part.title }}</span>
            {%- else -%}
              <span class="small fw-bold">{{ part.title }}</span>
            {%- endif -%}
          {%- endif -%}
        </li>
      {%- endfor -%}

      {%- if paginate.next -%}
        <li class="page-item col-1" style="max-width: 40px;">
          <a class="as-pagination-link text-body icon-wrap-md" data-page="{{ paginate.current_page | plus: 1 }}" href="{{ paginate.next.url }}{{ anchor }}" aria-label="{{ 'general.pagination.next' | t }}" >
            {%- render 'icon-chevron-right' -%}
          </a>
        </li>
      {%- endif -%}
      </ul>
    </nav>
  </div>
{%- endif -%}
